package de.andreavicentini.mehlsaecke.generate;

import org.magiclabs.html.model.*;
import java.util.*;
import de.andreavicentini.mehlsaecke.htmlmodel.*;
import de.andreavicentini.mehlsaecke.domain.*;

public class LayoutView implements ILayout {
  protected static String nl;
  public static synchronized LayoutView create(String lineSeparator)
  {
    nl = lineSeparator;
    LayoutView result = new LayoutView();
    nl = null;
    return result;
  }

  public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
  protected final String TEXT_1 = "";
  protected final String TEXT_2 = NL + NL + "<html>" + NL + "<head>" + NL + "<LINK REL =\"stylesheet\" TYPE=\"text/css\" HREF=\"saeckestyle.css\" TITLE=\"Style\">" + NL + "<META HTTP-EQUIV=\"Pragma\" CONTENT=\"no-cache\">" + NL + "<title>Mehls&auml;cke ";
  protected final String TEXT_3 = "| ";
  protected final String TEXT_4 = "</title>" + NL + "</head>" + NL + "" + NL + "<body>" + NL + "" + NL + "<div id=\"content\">";
  protected final String TEXT_5 = NL;
  protected final String TEXT_6 = NL + "</div>" + NL + "" + NL + "<div id=\"footer\">" + NL + "<a href=\"Years.html\">Zeitlicher Verlauf</a> | <a href=\"Saecke.html\">Zeig mir S&auml;cke!</a> | <a href=\"Mosaic.html\">Mosaiken</a> | <a href=\"\">Kontakt</a>" + NL + "</div>" + NL + "" + NL + "</body>" + NL + "</html>";

	public String generate(Object argument)
  {
    final StringBuffer stringBuffer = new StringBuffer();
    stringBuffer.append(TEXT_1);
    
Page page = (Page) argument;
Model model = page.getModel();

    stringBuffer.append(TEXT_2);
     if (page.getTitle() != null) { 
    stringBuffer.append(TEXT_3);
    stringBuffer.append( page.getTitle() );
     } 
    stringBuffer.append(TEXT_4);
    stringBuffer.append(TEXT_5);
    stringBuffer.append( page.renderContent() );
    stringBuffer.append(TEXT_6);
    return stringBuffer.toString();
  }
}